//
//  LLConstant.h
//  lrlzapp
//
//  Created by dl on 16/2/22.
//  Copyright © 2016年 lrlz. All rights reserved.
//

#ifndef LLConstant_h
#define LLConstant_h

typedef void (^VoidBlock)();

typedef BOOL (^BoolBlock)();

typedef int  (^IntBlock)();

typedef id   (^IDBlock)();

typedef void (^VoidBlock_int)(int);

typedef BOOL (^BoolBlock_int)(int);

typedef int  (^IntBlock_int)(int);

typedef id   (^IDBlock_int)(int);

typedef void (^VoidBlock_string)(NSString *);

typedef BOOL (^BoolBlock_string)(NSString *);

typedef int  (^IntBlock_string)(NSString *);

typedef id   (^IDBlock_string)(NSString *);

typedef void (^VoidBlock_id)(id);

typedef BOOL (^BoolBlock_id)(id);

typedef int  (^IntBlock_id)(id);

typedef id   (^IDBlock_id)(id);

#define LLSharedAppDelegate ((AppDelegate *)[UIApplication sharedApplication].delegate)
#define SYSTEM_VERSION              [[[UIDevice currentDevice] systemVersion] floatValue]   //系统版本号
#define STATUSBAR_HEIGHT            [[UIApplication sharedApplication] statusBarFrame].size.height //状态栏高
#define SCREEN_HEIGHT               [[UIScreen mainScreen] bounds].size.height
#define ClientVervion   [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]
#define SCREEN_HEIGHT               [[UIScreen mainScreen] bounds].size.height
#define FULL_HEIGHT                 (SCREEN_HEIGHT - ((SYSTEM_VERSION >= 7) ? 0 : STATUSBAR_HEIGHT))
#define FULL_WIDTH                  [[UIScreen mainScreen] bounds].size.width
#define FULL_HEIGHT                 (SCREEN_HEIGHT - ((SYSTEM_VERSION >= 7) ? 0 : STATUSBAR_HEIGHT))
#define SCREEN_WIDTH                FULL_WIDTH
///-----------
/// SSKeychain
///-----------

#define LL_KEYCHAIN_SERVICE_NAME                @"com.lrlz.lrlzapp"
#define LL_KEYCHAIN_PASSWORD                    @"Password"
#define LL_KEYCHAIN_ACCESS_TOKEN                @"AccessToken"
#define LL_KEYCHAIN_UUID                        @"UUID"
#define LL_NSUSERDEFAULT_RAW_LOGIN              @"RawLogin"

#define LL_NSUSERDEFAULT_LAST_LAUNCH_VER        @"LastLaunchVer"    // 上次首次进入APP的版本号
#define LL_NSUSERDEFAULT_ADVERTISEMENT          @"Advertisement"


//view   >=7 45+20，，，否则45
#define NAVBAR_HEIGHT               (45.f + ((SYSTEM_VERSION >= 7) ? STATUSBAR_HEIGHT : 0))
#define TAB_BAR_HEIGHT 49

//----------------------------- 适配，视图的矢量大小 start -------------------------------------
// 适配，UI设计图纸的基准，以iphone6为基准
#define UI_DESIGN_BASE_WIDTH        375.f
#define DEVICE_IS_IPHONE_4_OR_5     (fabs((double)FULL_WIDTH - (double)320) < DBL_EPSILON)
#define DEVICE_IS_IPHONE_6          (fabs((double)FULL_WIDTH - (double)375) < DBL_EPSILON)
#define DEVICE_IS_IPHONE_6_PLUS     (fabs((double)FULL_WIDTH - (double)414) < DBL_EPSILON)

// scale，默认都采用1.f倍率，只有当宽度&高度的大小取决于屏幕的宽度的时候，才使用SUIT_SCALE_320
#define SUIT_SCALE                  1.f
#define SUIT_SCALE_320              (FULL_WIDTH<UI_DESIGN_BASE_WIDTH ? 0.85f : 1.f)
#define SUIT_SCALE_ALL              (DEVICE_IS_IPHONE_4_OR_5?0.85f:(DEVICE_IS_IPHONE_6_PLUS?1.12f:1.f))

#define SUIT_LINE_WIDTH             (1.f / [UIScreen mainScreen].scale)
#define SUIT_LINE_ADJUST_OFFSET     ((1.f / [UIScreen mainScreen].scale) / 2.f)

// 默认320和375宽度的屏幕，都采用1.f倍率的字体，414宽度的屏幕采用1.12f倍率，当scale采用SUIT_SCALE_320时，相应的字体要采用SUIT_FONT_SCALE_320
//#define SUIT_FONT_SCALE             (DEVICE_IS_IPHONE_6_PLUS ? 1.12f : 1.f)
#define SUIT_FONT_SCALE             1.f
#define SUIT_FONT_SCALE_320         (DEVICE_IS_IPHONE_6_PLUS ? 1.12f : (DEVICE_IS_IPHONE_4_OR_5?0.85f:1.f))

#define SUIT_W(w)                   w*SUIT_SCALE
#define SUIT_H(h)                   h*SUIT_SCALE
// 四舍五入，处理, 精确到0.5f
#define SUIT_W_320(w)               round(w*SUIT_SCALE_320*2.f)/2.f
#define SUIT_H_320(h)               round(h*SUIT_SCALE_320*2.f)/2.f
// 四舍五入，处理，精确到1.f
#define SUIT_W_ALL(w)               round(w*SUIT_SCALE_ALL)
#define SUIT_H_ALL(h)               round(h*SUIT_SCALE_ALL)

//----------------------------- 适配，字体相关 start -------------------------------------
#define FONT(s)                     [UIFont systemFontOfSize:s]
//#define FONT(s)                    [UIFont fontWithName:@"MicrosoftYaHeiUILight" size:s]
#define BOLD_FONT(s)                [UIFont boldSystemFontOfSize:s]

#define SUIT_FONT(x)                FONT(round(x*SUIT_FONT_SCALE))       // 字体取整，适配
#define SUIT_BOLD_FONT(x)           BOLD_FONT(round(x*SUIT_FONT_SCALE))  // 粗体，字体取整，适配

// 在320宽的屏幕中，特殊时刻缩小字体
#define SUIT_FONT_320(x)            FONT(round(x*SUIT_FONT_SCALE_320))
#define SUIT_BOLD_FONT_320(x)       BOLD_FONT(round(x*SUIT_FONT_SCALE_320))

//获取图片的宽度和高度，参数是以iphone6尺寸为准
#define GET_WIDTH_ICO(width)        FULL_WIDTH/375.f*width
#define GET_HEIGHT_ICO(height)      FULL_WIDTH/375.f*height

//----------------------------- 新版本颜色色调 start -------------------------------------
#define UIColorFromRGBA(rgbValue, alphaValue) \
[UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0x00FF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0x0000FF))/255.0 \
alpha:alphaValue]

#define UIColorFromRGB(rgbValue)    UIColorFromRGBA(rgbValue, 1.f)

// 主题颜色
#define UI_COLOR_RED                UIColorFromRGB(0xEC1161)
#define UI_COLOR_GREY               UIColorFromRGB(0xD5D5D5)
#define UI_COLOR_GREEN              UIColorFromRGB(0x62BDD2)
#define UI_COLOR_LIGHT_GREEN        UIColorFromRGB(0xD0F0F8)
// 字体颜色
#define UI_COLOR_FONT_BLACK         UIColorFromRGB(0x333333)
#define UI_COLOR_FONT_GREY          UIColorFromRGB(0x666666)
#define UI_COLOR_FONT_LIGHT_GREY    UIColorFromRGB(0x999999)
// 分割线
#define UI_COLOR_LINE_GREY          UIColorFromRGB(0xE5E5E5)
#define UI_COLOR_LINE_LIGHT_GREY    UIColorFromRGB(0xF9F9F9)
// 底色
#define UI_COLOR_BG_GREY            UIColorFromRGB(0xEEEEEE)
#define UI_COLOR_BG_LIGHT_GREY      UIColorFromRGB(0xF7F7F7)


//----------------------------- 图片缩放适配(常用尺寸) start -------------------------------------
// 全屏宽图片大小
#define IMAGE_SIZE_FULL_SCREEN          600 //DEVICE_IS_IPHONE_6_PLUS?600:(DEVICE_IS_IPHONE_6?500:400)
// 半屏宽图片大小
#define IMAGE_SIZE_HALF_SCREEN          400 //DEVICE_IS_IPHONE_6_PLUS?300:(DEVICE_IS_IPHONE_6?270:240)
// 取原图
#define IMAGE_SIZE_ORIGIN               -1


// tableViewCell
#define IDENTIFIER_TABLEVIEW_CELL_STYLE1                @"IDENTIFIER_TABLEVIEW_CELL_STYLE1"
#define IDENTIFIER_TABLEVIEW_CELL_CART_ITEM             @"IDENTIFIER_TABLEVIEW_CELL_CART_ITEM"
#define IDENTIFIER_COLLECTIONVIEW_CELL_BANNER           @"IDENTIFIER_COLLECTIONVIEW_CELL_BANNER"
#define IDENTIFIER_COLLECTIONVIEW_CELL_BOTTOM_TITLE     @"IDENTIFIER_COLLECTIONVIEW_CELL_BOTTOM_TITLE"
#define IDENTIFIER_COLLECTIONVIEW_CELL_IMG              @"IDENTIFIER_COLLECTIONVIEW_CELL_IMG"
#define IDENTIFIER_HEADER_ACTIVITY_TILED                @"IDENTIFIER_HEADER_ACTIVITY_TILED"

#endif /* LLConstant_h */
